function formatData(time){
    if(time.length < 13) time = time*1000;
    let timestamp = new Date(Number(time));
    // 2020-4-28 23:58:37
    let origin = timestamp.toLocaleDateString().replace(/\//g, "-") + " " + timestamp.toTimeString().substr(0, 8);
    let date = formatTime(origin);
    // [ '2020-04-28', '2020-04-28 23:58:37' ]
    return [ ...date , time/1000 ];
}

function formatTime(time){
    let arr = [];
    // [ '2020', '4', '28' ]
    arr = time.split(' ')[0].split('-');
    arr[1].length < 2 ? arr[1] = `0${arr[1]}` : null;
    arr[2].length < 2 ? arr[2] = `0${arr[2]}` : null;
    return [arr.join('-'), `${arr.join('-')} ${time.split(' ')[1]}`];
}

module.exports.formatDate = formatData;